home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11312 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: digex.net!not-for-mail
  2. From: igor@access4.digex.net (Dan White)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: STRTOL, STRTUL,STRTOD functions
  5. Date: 22 Mar 1996 21:30:37 -0500
  6. Organization: Society for the Prevention of Paronomastic Defenestration
  7. Message-ID: <4ivnod$afn@access4.digex.net>
  8. References: <4ifjao$j5c@news1.h1.usa.pipeline.com> <314ed2d3.110217@news.fred.net>
  9. NNTP-Posting-Host: access4.digex.net
  10.  
  11. In article <314ed2d3.110217@news.fred.net>,
  12. Scott Allen <bitmask@bigdog.fred.net> wrote:
  13. >fredrics@usa.pipeline.com(Fredric Smith) wrote:
  14. >
  15. >>I cannot find sample pieces of code for these..would appreciate some
  16. >>help..if someone can 
  17. >> 
  18. >
  19. >int main(void)
  20. >{
  21. >   char *string = "87654321", *endptr;
  22. >   long lnumber;
  23. >
  24. >  /* strtol converts string to long integer  */
  25. >  /* strtoul converts a string to an unsigned long */
  26. >  /* strtod converts a string to a double */
  27. >
  28. >  /*  *endptr will point to the character that stopped the scan */
  29. >
  30. >
  31. >   lnumber = strtol(string, &endptr, 10);
  32. >
  33. >   printf("string = %s  long = %ld\n", string, lnumber);
  34. >
  35. >   return 0;
  36. >}
  37. >
  38. >
  39. >Hope this helps, 
  40.  
  41. ...and what is wrong with using sscanf ?
  42.  
  43. ------------------------------------------------------------------------
  44.                                                                Dan White
  45. ------------------------------------------------------------------------
  46. "Sometimes  I  think  the  surest  sign  that  intelligent  life exists
  47.  elsewhere  in the universe is that none of it has tried to contact us."
  48.                                                   Calvin (Bill Waterson)
  49.